package com.sanery.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.sanery.entity.MySite;
import com.sanery.service.SiteService;
import com.sanery.service.impl.SiteServiceImpl;

@Controller
public class ListController {
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public String list(HttpSession session, Model m) {
		Integer userid = (Integer) session.getAttribute("userid");
		if (userid == null) {
			return "redirect:/login";
		}
		// 查询数据库中所有的site
		SiteService service = new SiteServiceImpl();
		List<MySite> list = service.getAllSite(userid);

		// 将 list 发送给jsp
		m.addAttribute("list", list);

		return "/list";
	}
}
